﻿<UserControl x:Class="Albatross.SharePoint.Explorer.Views.ExplorerView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
			 xmlns:common="clr-namespace:Albatross.WPF.Common.Views;assembly=Albatross.WPF.Common"
			xmlns:controls="clr-namespace:Albatross.WPF.Common.Controls;assembly=Albatross.WPF.Common"
			xmlns:local="clr-namespace:Albatross.SharePoint.Explorer.Views"
			xmlns:vm="clr-namespace:Albatross.SharePoint.Explorer.ViewModels"
			xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             mc:Ignorable="d" 
             d:DesignHeight="500" d:DesignWidth="600">
	<UserControl.Resources>
		<ResourceDictionary>
			<ResourceDictionary.MergedDictionaries>
				<ResourceDictionary Source="/Albatross.Resources;component/toolbar.xaml"/>
			</ResourceDictionary.MergedDictionaries>

			<HierarchicalDataTemplate x:Key="treeviewitem template" DataType="{x:Type vm:ClientObjectViewModel}" ItemsSource="{Binding Children}">
				<TextBlock Text="{Binding TreeItemTitle}" Padding="3"/>
			</HierarchicalDataTemplate>

			<Style TargetType="TreeViewItem" x:Key="treeviewitem">
				<Setter Property="FontFamily" Value="Segoe UI"/>
				<Setter Property="FontSize" Value="12" />
				<Setter Property="Margin" Value="0"/>
				<Setter Property="Padding" Value="6 2 6 2"/>
				<Setter Property="Foreground" Value="Black"/>
				<Setter Property="FontWeight" Value="Normal"/>
				<Setter Property="BorderThickness" Value="0"/>
				<Setter Property="VerticalContentAlignment" Value="Center"/>
				<Setter Property="BorderBrush" Value="Silver"/>
				<Setter Property="Background" Value="White"/>
				<Setter Property="IsSelected" Value="{Binding IsSelected}"/>
				<Setter Property="IsExpanded" Value="{Binding IsExpanded}"/>
				<Style.Triggers>
					<DataTrigger Binding="{Binding IsHidden}" Value="True">
						<Setter Property="Opacity" Value=".5"/>
					</DataTrigger>
				</Style.Triggers>
			</Style>

			<DataTemplate x:Key="leftheader template">
				<Border BorderBrush="Silver" BorderThickness="1">
					<DockPanel>
						<ToggleButton Style="{StaticResource collapse btn}" />
						<ToolBar Style="{StaticResource toolbar}">
							<Button>
								<DockPanel>
									<Image Source="/Albatross.Resources;component/Images/refresh.png" Style="{StaticResource toolbar img}"/>
									<TextBlock Style="{StaticResource toolbar text}">Refresh</TextBlock>
								</DockPanel>
							</Button>
						</ToolBar>
					</DockPanel>
				</Border>
			</DataTemplate>

			<DataTemplate x:Key="leftcollapsebar template">
				<ToggleButton IsChecked="{Binding IsLeftExpanded, RelativeSource={RelativeSource AncestorType=controls:AlbatrossDockPanel}}" Style="{StaticResource expand btn}" />
			</DataTemplate>
		</ResourceDictionary>
	</UserControl.Resources>

	<controls:AlbatrossDockPanel DockBottom="False" DockTop="False" DockRight="True" DockLeft="True" IsLeftExpanded="True" 
								 LeftHeaderTemplate="{StaticResource leftheader template}" LeftCollapseBarTemplate="{StaticResource leftcollapsebar template}">
		<controls:AlbatrossDockPanel.Left>
			<TreeView x:Name="Tree"
								  ItemsSource="{Binding Sites}" 
								  ItemContainerStyle="{StaticResource treeviewitem}"
								  ItemTemplate="{StaticResource treeviewitem template}" Padding="3" BorderThickness="0">
				<i:Interaction.Behaviors>
					<common:Behavior_TreeViewSelectionChangedCommand Command="{Binding SelectedItemChangedCommand}" />
				</i:Interaction.Behaviors>
			</TreeView>
		</controls:AlbatrossDockPanel.Left>
		<controls:AlbatrossDockPanel.Right>
			<ContentControl common:Attached.CompositeRegion="Details" />
		</controls:AlbatrossDockPanel.Right>
		<ContentControl common:Attached.CompositeRegion="Center" />
	</controls:AlbatrossDockPanel>

	<common:Attached.ViewService>
		<common:CompositeViewService DefaultRegion="Center" />
	</common:Attached.ViewService>
	<i:Interaction.Behaviors>
		<common:ViewServiceDispatcher ViewService="{Binding ViewService, Mode=OneWayToSource}"/>
	</i:Interaction.Behaviors>
</UserControl>
